﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HsTec.Mobile.Green.SqlServerDAL;

public partial class SysManage_right : System.Web.UI.Page
{
    public string sHtml = "", sHtml2 = "";
    News MyNews = new News();
    DataFile MyDF = new DataFile();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            if ((string)Session["Baimasoft_User_LogonID"] == null)
            {
                Response.Redirect("../ReLogon.aspx");
            }
            else
            {
                //string sLogonName = (string)Session["Baimasoft_Pers_Name"];  //姓名
                //if (sLogonName.Length > 0)
                //{
                //    LogonName.Text = sLogonName;
                //}
            }

            //int iNews = 0;
            //string sNews = "<font color =\"#009900\">";
            //DataTable MyDT = MyNews.GetTopNews("",15);
            //foreach (DataRow dr in MyDT.Rows)
            //{
            //    iNews++;
            //    sNews += "<tr><td ><a href=\"../News/NewDetail.aspx?ID=" + dr["ID"].ToString().Trim() + "\" target=\"_blank\" >" + dr["Title"].ToString().Trim() + "</a></td><td style=\"width:100;\">" + string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(dr["Addtime"].ToString().Trim())) + "</td></tr>";
            //}
            //sNews += "</font>";

            //int iFiles = 0;
            //string sFile = "<font color =\"#009900\">";
            //DataTable MyDT2 = MyDF.GetTopDataFiles("",15);
            //foreach (DataRow dr2 in MyDT2.Rows)
            //{
            //    iFiles++;
            //    sFile += "<tr><td >" + dr2["Name"].ToString().Trim() + "</td><td style=\"width:100;\">" + string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(dr2["FileCreatDT"].ToString().Trim())) + "</td></tr>";
            //}
            //sFile += "</font>";

            //sHtml += "<table style =\"width :100%;\"  class=\"table\"> ";

            //if (iNews > 0)
            //{
            //    sHtml += "<tr><TD><font color =\"#009900\"><b>【最新信息】</b></font></TD></tr>";
            //    sHtml += sNews;
            //}

            //sHtml += "</table>";

            //sHtml2 += "<table style =\"width :100%;\"> ";
            //if (iFiles > 0)
            //{
            //    sHtml2 += "<tr><td colspan=\"2\" style=\"20;\"></td></tr><tr><td><font color =\"#009900\"><b>【最新入库资料】</b></font></td></tr>";
            //    sHtml2 += sFile;
            //}

            //sHtml2 += "</table>";


            GridView1.Attributes.Add("BorderColor", "LightSkyBlue");
            GridView2.Attributes.Add("BorderColor", "LightSkyBlue");

            NewsDataBind();
            DocDataBind();
        }


    }

    protected void NewsDataBind()
    {
        GridView1.DataSource = MyNews.GetTopNews("", 15);
        GridView1.DataBind();
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            if (e.Row.RowIndex % 2 != 0)
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#EFEFF8')");
            }
            else
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#F9F9FB')");
            }
        }
    }


    protected void DocDataBind()
    {
        GridView2.DataSource = MyDF.GetTopDataFiles("", 15);
        GridView2.DataBind();
    }

    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            if (e.Row.RowIndex % 2 != 0)
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#EFEFF8')");
            }
            else
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#F9F9FB')");
            }
        }
    }

}
